package com.tddx.activiti.business.sys.controller.systuser;

import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.tddx.activiti.base.BaseController;
import com.tddx.activiti.business.sys.entity.systuser.SysTuserEntity;
import com.tddx.activiti.business.sys.service.systuser.SysTuserService;

/**
 * control layer 控制层 
 * @Auth yanweizhao 
 */
@Controller
@RequestMapping("sys/systuser")
public class SysTuserCtrl extends BaseController<SysTuserEntity, String>{

	@Autowired private SysTuserService service;

	@RequestMapping({"view{oper}"})
	@RequiresAuthentication
	@RequiresPermissions(value={"sys:user:view"}, logical=Logical.OR)
	public String view(@PathVariable String oper, Long id, ModelMap map){
		map.put("oper", oper);
		if("result".equals(oper)){
			return "modules/sys/sysTuserList";
		}
		if(id!=null){
			SysTuserEntity entity = service.findOne(id);
			map.put("entity", entity);
		}
		return "modules/sys/sysTuserInput";
		
	}
	
	@RequestMapping("save")
	@ResponseBody
	public Object save(SysTuserEntity entity){
		entity = service.save(entity);
		return entity;
	}
	
	@RequestMapping("delete")
	@ResponseBody
	public Object delete(String ids){
		service.delete(ids);
		return ids;
	}
	
	@RequestMapping({"list", ""})
	@ResponseBody
	public Object findList(){
		Object obj = service.findList();
		return obj;
	}
	
}
